package router

import (
	"github.com/gogf/csrf/v2"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
)

func init() {
	g.Server().Group("/api", func(group *ghttp.RouterGroup) {
		group.Middleware(func(r *ghttp.Request) {
			csrf.New()
			r.Response.CORSDefault()

			r.Middleware.Next()
		})

		group.Group("/", func(group *ghttp.RouterGroup) { // 前端
			//group.Middleware(func(r *ghttp.Request) {
			//})

			group.Group("/common", func(group *ghttp.RouterGroup) { // 通用
				Common(group)
			})
			group.Group("/advertise", func(group *ghttp.RouterGroup) { // 广告
				Advertise(group)
			})
			group.Group("/message", func(group *ghttp.RouterGroup) { // 消息
				Message(group)
			})
			group.Group("/passport", func(group *ghttp.RouterGroup) { // 用户
				Passport(group)
			})
			group.Group("/payment", func(group *ghttp.RouterGroup) { // 支付
				Payment(group)
			})
			group.Group("/vip", func(group *ghttp.RouterGroup) { // 会员
				Vip(group)
			})
			group.Group("/task", func(group *ghttp.RouterGroup) { // 任务
				Task(group)
			})
			group.Group("/server", func(group *ghttp.RouterGroup) { // 服务
				Server(group)
			})
			group.Group("/apps", func(group *ghttp.RouterGroup) { // 应用
				Apps(group)
			})
		})
		group.Group("/backend", func(group *ghttp.RouterGroup) { // 后端
			group.Middleware(func(r *ghttp.Request) {
			})

			group.Group("/common", func(group *ghttp.RouterGroup) { // 通用
				CommonBackend(group)
			})
			group.Group("/advertise", func(group *ghttp.RouterGroup) { // 广告
				AdvertiseBackend(group)
			})
			group.Group("/message", func(group *ghttp.RouterGroup) { // 消息
				MessageBackend(group)
			})
			group.Group("/passport", func(group *ghttp.RouterGroup) { // 用户
				PassportBackend(group)
			})
			group.Group("/payment", func(group *ghttp.RouterGroup) { // 支付
				PaymentBackend(group)
			})
			group.Group("/vip", func(group *ghttp.RouterGroup) { // 会员
				VipBackend(group)
			})
			group.Group("/task", func(group *ghttp.RouterGroup) { // 任务
				TaskBackend(group)
			})
			group.Group("/server", func(group *ghttp.RouterGroup) { // 服务
				ServerBackend(group)
			})
			group.Group("/apps", func(group *ghttp.RouterGroup) { // 应用
				AppsBackend(group)
			})
		})
	})
}
